package com.ruoyi.bizsys.service.impl;

import java.util.List;
import java.util.Arrays;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.common.enums.RspEnmu;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
    import com.ruoyi.bizsys.mapper.RealNameAuthLogMapper;
import com.ruoyi.bizsys.domain.RealNameAuthLog;
import com.ruoyi.bizsys.service.IRealNameAuthLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.CollectionUtils;


/**
 * 实名认证日志Service业务层处理
 *
 * @author african-loan
 * @date 2021-12-30
 */
@Service
public class RealNameAuthLogServiceImpl extends ServiceImpl<RealNameAuthLogMapper,RealNameAuthLog> implements IRealNameAuthLogService {

    /**
     * 查询实名认证日志
     *
     * @param id 实名认证日志ID
     * @return 实名认证日志
     */
    @Override
    public RealNameAuthLog selectRealNameAuthLogById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询实名认证日志列表
     *
     * @param realNameAuthLog 实名认证日志
     * @return 实名认证日志
     */
    @Override
    public List<RealNameAuthLog> selectRealNameAuthLogList(RealNameAuthLog realNameAuthLog) {
        return this.list(new QueryWrapper<>(realNameAuthLog).last("order by id desc"));
    }

    /**
     * 新增实名认证日志
     *
     * @param realNameAuthLog 实名认证日志
     * @return 结果
     */
            @Override
    public int insertRealNameAuthLog(RealNameAuthLog realNameAuthLog) {
                                                                                                                                                                                                                                                                                                                                                                                                                                realNameAuthLog.setCreateTime(DateUtils.getNowDate());
                                                                    return baseMapper.insert(realNameAuthLog);
    }

    /**
     * 修改实名认证日志
     *
     * @param realNameAuthLog 实名认证日志
     * @return 结果
     */
            @Override
    public int updateRealNameAuthLog(RealNameAuthLog realNameAuthLog) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        realNameAuthLog.setUpdateTime(DateUtils.getNowDate());
                            return baseMapper.updateById(realNameAuthLog);
    }

    /**
     * 批量删除实名认证日志
     *
     * @param ids 需要删除的实名认证日志ID
     * @return 结果
     */
            @Override
    public int deleteRealNameAuthLogByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除实名认证日志信息
     *
     * @param id 实名认证日志ID
     * @return 结果
     */
    @Override
    public int deleteRealNameAuthLogById(Long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public boolean appendPhones(String custNo, String phone) {
        UpdateWrapper<RealNameAuthLog> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set("phone_number",phone).eq("cust_no",custNo).last("order by id desc limit 1");
        return update(updateWrapper);
    }


}
